﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Csla;
using Csla.Data;

namespace Aiss.Sync
{
    [Serializable]
    public class Table:Csla.BusinessBase<Table>
    {
        string name = "";
        Columns columns;

        private bool selected = false;
        public bool Selected
        {
            get { return selected; }
            set { selected = value; }
        }

        private int object_id;

        public int Object_id
        {
            get { return object_id; }
            set { object_id = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public Columns Columns
        {
            get { return columns; }
            set { columns = value; }
        }

        private Table()
        {
            columns = new Columns();
        }

        public Table(string name)
        {
            columns = new Columns();
        }

        public static Table GetTable(Csla.Data.SafeDataReader dr)
        {
            Table t = new Table();
            t.Fetch(dr);
            return t;
        }

        private void Fetch(Csla.Data.SafeDataReader dr)
        {
            object_id = dr.GetInt32(0);
            name = dr.GetString(1);
        }
    }
}
